<template>
    <el-form :model="ProjectData" label-width="120px" style="padding: 20px 0px" ref="Engineering">
        <el-row>
            <el-col :span="11">
                <el-form-item label="项目名称">
                    <el-input v-model="ProjectData.ProjectName" placeholder="项目名称"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="11" :offset="1">
                <!-- <el-form-item label="负责人" prop="HeadUserId">
           <el-select v-model="ProjectData.HeadUserId" filterable style="width: 100%">
               <el-option v-for="item in $store.state.AllUsers" :value="item.Id"
                          :label="item.UserName"></el-option>
           </el-select>
       </el-form-item> -->
                <el-form-item label="负责人">
                    <el-select width="100%" v-model="ProjectData.HeadUserId" filterable placeholder="请选择申请人"
                        style="width:100%">
                        <el-option v-for="(v, k) in $store.state.AllUsers" :value="v.Id + ''" :data-userid="v.Id"
                            :label="v.UserName" v-text="v.UserName" />
                    </el-select>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="11">
                <el-form-item label="合同总价">
                    <el-input v-model="ProjectData.EstimatedContractAmount" placeholder="合同总价"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="11" :offset="1">
                <el-form-item label="已付款金额">
                    <el-input v-model="ProjectData.CollectionAmount" placeholder="已付款金额"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="11">
                <el-form-item label="甲方信息">
                    <el-input v-model="ProjectData.PartA" placeholder="甲方信息"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="11" :offset="1">
                <el-form-item label="备注">
                    <el-input v-model="ProjectData.Remark" placeholder="备注"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="22" :offset="1" align="center">
                <el-button type="success" @click="UpdataProjectRecord">保存</el-button>
            </el-col>
        </el-row>
    </el-form>
</template>

<script>
import * as publicjs from "../../../public/Scriput/Public";

export default {
    name: "Approval",
    props: {
        ProjectData: {
            type: Object,
            required: true,
            default: null,
        },
        AllUsers: {
            type: Array,
            required: true
        },
    },
    data() {
        return {

        }
    },
    created() {
        this.AllProjectUnitAttribute = publicjs.GetAllProjectUnitAttribute(this.$http)
        this.AllContract = publicjs.GetAllContract(this.$http)
        this.GetUsers();
        this.test();
    },
    methods: {
        test() {
            console.log(123123);
            console.log(this.$store.state.user);
        },
        GetUsers() {
            _this.$http.post('Project1/GetNotDateUser', { StartDate: this.Engineering_Project.StartDate, EndDate: this.Engineering_Project.EndDate }).then(res => {
                _this.AllUsers = res.data.Data
                console.log(res.data.Data);
            }).catch(e => {
                _this.$message.error('服务器出现问题');
            });
        },
        UpdataProjectRecord() {
            this.$http.post('Project1/UpdateProjectRecord', { Project: this.ProjectData }).then(res => {
                if (res.data.IsSuccess) {
                    this.$message.success(res.data.Msg)
                    this.$parent.$parent.Approval_dialog.show = false
                    this.$parent.$parent.formdata()
                } else {
                    this.$message.warning(res.data.Msg)
                }
            }).catch(() => {
                this.$message.error('服务器异常!')
            })
        },

    },
}
</script>

<style scoped></style>
